﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO.Compression;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Desaware.MachineLicense40;
using FMS.Formulation.Licensing.Objects;
using System.Windows.Forms;
using System.Xml;
using FMS.Formulation.Licensing.Engine;

namespace WindowsFormsApp1
{

    public class ActivationProcessor
    {
        private const int MAXACTIVATIONTRIES = 6;

        private const int TRIESBEFORECOPY = 0;

        private string _languageID = string.Empty;

        private string _fontName = "Arial";

        private float _fontSize = 8.25f;

        private byte _fontCharSet = 0;

        private bool _licenseIsGood = false;

        private int _desawareServerTimeout = 0;

        private DateTime _lastValidationAttempt = DateTime.MinValue;

        private string _licenseData = string.Empty;

        private string _errorMessage = string.Empty;

        private Language _languageFile = new Language();

        public string ErrorMessage => _errorMessage;

        public int DesawareServerTimeout => _desawareServerTimeout;

        public DateTime LastValidationAttempt => _lastValidationAttempt;

        public string LicenseData => _licenseData;

        public ActivationProcessor()
        {
            InitLanguage();
            GetLicenseConfiguration();
        }

        public ActivationProcessor(string LanguageID, string FontName, float FontSize, byte FontCharSet)
        {
            _languageID = LanguageID;
            _fontName = FontName;
            _fontSize = FontSize;
            _fontCharSet = FontCharSet;
            InitLanguage();
            GetLicenseConfiguration();
        }

        private void InitLanguage()
        {
            _languageFile.GetLanguage(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), _languageID);
        }

        public ReturnCodes.ReturnCode ReadLicenseCertificate(out FMS.Formulation.Licensing.License.License theLicense)
        {
            _errorMessage = string.Empty;
            theLicense = new FMS.Formulation.Licensing.License.License();
            FMS.Formulation.Licensing.License.License license = new FMS.Formulation.Licensing.License.License();
            string text = LicensePath.PathToCertificate();
            if (!File.Exists(text))
            {
                _errorMessage = _languageFile.GetLangString(16);
                return ReturnCodes.ReturnCode.LicenseNotActivated;
            }
            ReadCertificate readCertificate = new ReadCertificate();
            if (!readCertificate.ReadLicenseCertificate(text, license, out var LicenseIsTrial, out var IsDisabled))
            {
                _errorMessage = _languageFile.GetLangString(17);
                return ReturnCodes.ReturnCode.LicenseNotValid;
            }
            _licenseData = readCertificate.LicenseData;
            if (IsDisabled)
            {
                theLicense = license;
                _errorMessage = _languageFile.GetLangString(38) + Environment.NewLine + _languageFile.GetLangString(49) + " " + _languageFile.GetLangString(50);
                return ReturnCodes.ReturnCode.LicenseHasExpired;
            }
            if (!LicenseIsTrial)
            {
                if (readCertificate.ServerDataBad)
                {
                    string text2 = _languageFile.GetLangString(18) + Environment.NewLine;
                    if (readCertificate.ErrorMessage.Length > 0)
                    {
                        text2 = text2 + readCertificate.ErrorMessage + Environment.NewLine;
                    }
                    _errorMessage = text2;
                    return ReturnCodes.ReturnCode.LicenseNotValid;
                }
                if (readCertificate.IsTempActivation)
                {
                    _errorMessage = _languageFile.GetLangString(19);
                    return ReturnCodes.ReturnCode.LicenseNotActivated;
                }
                theLicense = license;
                DesawareInterface desawareInterface = new DesawareInterface(_desawareServerTimeout);
                string text3 = desawareInterface.CheckLicense(text);
                if (text3.Length > 0)
                {
                    _errorMessage = text3;
                    return ReturnCodes.ReturnCode.LicenseNotValid;
                }
            }
            else
            {
                theLicense = license;
            }
            return ReturnCodes.ReturnCode.LicenseIsGranted;
        }

        public bool ProcessNewActivationCode()
        {
            bool result = false;
            _errorMessage = string.Empty;
            string licenseLocation = LicensePath.PathToCertificate();
            DesawareInterface desawareInterface = new DesawareInterface(_desawareServerTimeout);
            ClientLicense desawareClientLicense = new ClientLicense();//desawareInterface.GetDesawareClientLicense();
            int num = 0;
            bool flag = false;
            do
            {
                _errorMessage = string.Empty;
                if (num >= 6)
                {
                    flag = true;
                    break;
                }
                frmActivationCodeEntry frmActivationCodeEntry2 = ((num >= 0) ? new frmActivationCodeEntry(desawareClientLicense, displayCopyLicenseButton: true, _fontName, _fontSize, _fontCharSet, _languageFile) : new frmActivationCodeEntry(desawareClientLicense, displayCopyLicenseButton: false, _fontName, _fontSize, _fontCharSet, _languageFile));
                _licenseIsGood = false;
                frmActivationCodeEntry2.OptionClicked += theEntryForm_OptionClicked;
                frmActivationCodeEntry2.Width = 400;
                DialogResult dialogResult = frmActivationCodeEntry2.ShowDialog();
                //frmActivationCodeEntry2.OptionClicked -= theEntryForm_OptionClicked;
                if (dialogResult == DialogResult.OK)
                {
                    try
                    {
                        bool codeReUseWarning = false;
                        if (desawareInterface.InstallClientLicense(frmActivationCodeEntry2.ActivationCode, licenseLocation, out var errorMessage, AllowDeferred: false, suppressMessages: false, ref codeReUseWarning) == InstallClientLicenseResults.LicenseIsGood)
                        {
                            result = true;
                            flag = true;
                        }
                        else
                        {
                            _errorMessage = errorMessage;
                        }
                    }
                    catch (Exception ex)
                    {
                        _errorMessage = ex.Message;
                        if (ex.InnerException != null && !string.IsNullOrEmpty(ex.InnerException.Message))
                        {
                            _errorMessage = _errorMessage + Environment.NewLine + ex.InnerException.Message;
                        }
                    }
                    if (!string.IsNullOrEmpty(_errorMessage))
                    {
                        MessageBox.Show(_errorMessage, _languageFile.GetLangString(20), MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    }
                }
                else
                {
                    result = _licenseIsGood;
                    flag = true;
                }
                num++;
            }
            while (!flag);
            return result;
        }

        private void theEntryForm_OptionClicked(object sender, ActivationCodeEntryEventArgs e)
        {
            if (e.Option == activationOptions.CopyTheLicense)
            {
                string licenseLocation = LicensePath.PathToCertificate();
                DesawareInterface desawareInterface = new DesawareInterface(_desawareServerTimeout);
                ClientLicense desawareClientLicense = desawareInterface.GetDesawareClientLicense();
                if (CreateDeferredCertificateAndCopy(desawareInterface, desawareClientLicense, licenseLocation, e.ActivationCode))
                {
                    _licenseIsGood = true;
                    e.Cancel = true;
                }
            }
            else if (e.Option == activationOptions.InstallLicense)
            {
                string licenseLocation = LicensePath.PathToCertificate();
                if (InstallALicense(licenseLocation))
                {
                    _licenseIsGood = true;
                    e.Cancel = true;
                }
            }
        }

        public bool ProcessUpdateLicense(string ActivationCode)
        {
            bool result = false;
            _errorMessage = string.Empty;
            string licenseLocation = LicensePath.PathToCertificate();
            try
            {
                DesawareInterface desawareInterface = new DesawareInterface(_desawareServerTimeout);
                bool codeReUseWarning = false;
                if (desawareInterface.InstallClientLicense(ActivationCode, licenseLocation, out var errorMessage, AllowDeferred: false, suppressMessages: true, ref codeReUseWarning) == InstallClientLicenseResults.LicenseIsGood)
                {
                    result = true;
                }
                else
                {
                    _errorMessage = errorMessage;
                }
            }
            catch (Exception ex)
            {
                _errorMessage = ex.Message;
                if (ex.InnerException != null && !string.IsNullOrEmpty(ex.InnerException.Message))
                {
                    _errorMessage = _errorMessage + Environment.NewLine + ex.InnerException.Message;
                }
            }
            return result;
        }

        public void DestroyCertificateSignature()
        {
            string certificateURL = LicensePath.PathToCertificate();
            ReadCertificate readCertificate = new ReadCertificate();
            readCertificate.DestroyCertificateSignature(certificateURL);
        }

        private bool CreateDeferredCertificateAndCopy(DesawareInterface di, ClientLicense theClientLicense, string licenseLocation, string activationCode)
        {
            bool result = false;
            Cursor.Current = Cursors.WaitCursor;
            string directoryName = Path.GetDirectoryName(licenseLocation);
            string text = Path.Combine(directoryName, "ManualFormulation.dlsc");
            InstallClientLicenseResults installClientLicenseResults = InstallClientLicenseResults.LicenseWasNotCreated;
            string errorMessage;
            try
            {
                bool codeReUseWarning = false;
                installClientLicenseResults = di.InstallClientLicense(activationCode, text, out errorMessage, AllowDeferred: true, suppressMessages: true, ref codeReUseWarning);
            }
            catch (Exception ex)
            {
                errorMessage = ex.Message;
                if (ex.InnerException != null && !string.IsNullOrEmpty(ex.InnerException.Message))
                {
                    errorMessage = errorMessage + Environment.NewLine + ex.InnerException.Message;
                }
            }
            Cursor.Current = Cursors.Default;
            if (!string.IsNullOrEmpty(errorMessage))
            {
                MessageBox.Show(errorMessage, _languageFile.GetLangString(20), MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
            switch (installClientLicenseResults)
            {
                case InstallClientLicenseResults.LicenseIsGood:
                    try
                    {
                        DeleteFile(licenseLocation);
                        File.Move(text, licenseLocation);
                        result = true;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, _languageFile.GetLangString(20), MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    }
                    break;
                case InstallClientLicenseResults.DeferredLicenseHasBeenCreated:
                    CopyManualLicenseFile(text);
                    break;
            }
            return result;
        }

        public void LaunchRegistration(bool InitialActivation)
        {
        }

        public string GetLangString(int LangID)
        {
            return _languageFile.GetLangString(LangID);
        }

        private bool InstallALicense(string licenseLocation)
        {
            bool result = false;
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.AddExtension = true;
            openFileDialog.CheckFileExists = true;
            openFileDialog.CheckPathExists = true;
            openFileDialog.DefaultExt = ".dlsc";
            openFileDialog.FileName = "";
            openFileDialog.Filter = "License Files *.dlsc|*.dlsc";
            openFileDialog.FilterIndex = 0;
            openFileDialog.InitialDirectory = "";
            openFileDialog.Multiselect = false;
            openFileDialog.RestoreDirectory = true;
            openFileDialog.ShowReadOnly = false;
            openFileDialog.SupportMultiDottedExtensions = false;
            openFileDialog.Title = _languageFile.GetLangString(8);
            openFileDialog.ValidateNames = true;
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                string fileName = openFileDialog.FileName;
                string text = string.Empty;
                ReadCertificate readCertificate = new ReadCertificate();
                FMS.Formulation.Licensing.License.License theLicense = new FMS.Formulation.Licensing.License.License();
                if (readCertificate.ReadLicenseCertificate(fileName, theLicense, out var LicenseIsTrial, out var _))
                {
                    if (!LicenseIsTrial && readCertificate.ServerDataBad)
                    {
                        text = _languageFile.GetLangString(35) + Environment.NewLine + readCertificate.ErrorMessage + Environment.NewLine;
                    }
                }
                else
                {
                    text = _languageFile.GetLangString(34);
                }
                if (text.Length > 0)
                {
                    MessageBox.Show(text, _languageFile.GetLangString(20), MessageBoxButtons.OK, MessageBoxIcon.Hand);
                }
                else
                {
                    try
                    {
                        File.Copy(fileName, licenseLocation, overwrite: true);
                        result = true;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, _languageFile.GetLangString(20), MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    }
                }
            }
            return result;
        }

        private void GetLicenseConfiguration()
        {
            _desawareServerTimeout = 0;
            _lastValidationAttempt = DateTime.MinValue;
            string path = LicensePath.PathToCertificate();
            string text = Path.Combine(Path.GetDirectoryName(path), "LicenseConfiguration.xml");
            bool flag = true;
            XmlDocument xmlDocument = new XmlDocument();
            if (File.Exists(text))
            {
                try
                {
                    xmlDocument.Load(text);
                    XmlNodeList elementsByTagName = xmlDocument.GetElementsByTagName("LastValidationAttempt");
                    if (elementsByTagName.Count > 0)
                    {
                        string value = elementsByTagName.Item(0).ChildNodes.Item(0).Value;
                        _lastValidationAttempt = DateTime.ParseExact(value, "yyyy-MM-dd", CultureInfo.InvariantCulture);
                        if (_lastValidationAttempt > DateTime.Now)
                        {
                            _lastValidationAttempt = DateTime.MinValue;
                        }
                        flag = false;
                    }
                }
                catch
                {
                }
                if (!flag)
                {
                    try
                    {
                        XmlNodeList elementsByTagName = xmlDocument.GetElementsByTagName("ServerTimeout");
                        if (elementsByTagName.Count > 0)
                        {
                            string value2 = elementsByTagName.Item(0).ChildNodes.Item(0).Value;
                            _desawareServerTimeout = 0;
                            int.TryParse(value2, out _desawareServerTimeout);
                        }
                    }
                    catch
                    {
                    }
                }
            }
            if (flag)
            {
                SaveLicenseConfiguration(DateTime.MinValue);
            }
        }

        public void SaveLicenseConfiguration(DateTime LastValidationAttempt)
        {
            _lastValidationAttempt = LastValidationAttempt;
            string path = LicensePath.PathToCertificate();
            string text = Path.Combine(Path.GetDirectoryName(path), "LicenseConfiguration.xml");
            bool flag = true;
            XmlDocument xmlDocument = new XmlDocument();
            if (File.Exists(text))
            {
                try
                {
                    File.SetAttributes(text, FileAttributes.Normal);
                }
                catch
                {
                }
                try
                {
                    xmlDocument.Load(text);
                    XmlNodeList elementsByTagName = xmlDocument.GetElementsByTagName("LastValidationAttempt");
                    if (elementsByTagName.Count > 0)
                    {
                        flag = false;
                    }
                }
                catch
                {
                }
            }
            if (flag)
            {
                xmlDocument = new XmlDocument();
                XmlDeclaration newChild = xmlDocument.CreateXmlDeclaration("1.0", null, null);
                xmlDocument.AppendChild(newChild);
                XmlElement xmlElement = xmlDocument.CreateElement("LicenseConfiguration", "http://www.feedsys.com");
                xmlDocument.AppendChild(xmlElement);
                XmlElement xmlElement2 = xmlDocument.CreateElement("ServerTimeout", string.Empty);
                xmlElement.AppendChild(xmlElement2);
                xmlElement2.InnerText = "0";
                XmlElement xmlElement3 = xmlDocument.CreateElement("LastValidationAttempt", string.Empty);
                xmlElement.AppendChild(xmlElement3);
                xmlElement3.InnerText = string.Format(CultureInfo.InvariantCulture, "{0:yyyy-MM-dd}", new object[1] { LastValidationAttempt });
            }
            else
            {
                XmlNodeList elementsByTagName2 = xmlDocument.GetElementsByTagName("LastValidationAttempt");
                if (elementsByTagName2.Count > 0)
                {
                    elementsByTagName2.Item(0).ChildNodes.Item(0).Value = string.Format(CultureInfo.InvariantCulture, "{0:yyyy-MM-dd}", new object[1] { LastValidationAttempt });
                }
            }
            try
            {
                xmlDocument.Save(text);
            }
            catch
            {
            }
        }

        private void DeleteFile(string fileToDelete)
        {
            try
            {
                if (File.Exists(fileToDelete))
                {
                    try
                    {
                        File.SetAttributes(fileToDelete, FileAttributes.Normal);
                    }
                    catch
                    {
                    }
                    File.Delete(fileToDelete);
                }
            }
            catch
            {
            }
        }

        public void CopyManualLicenseFile(string licenseLocation)
        {
            if (!File.Exists(licenseLocation))
            {
                return;
            }
            SaveFileDialog saveFileDialog = new SaveFileDialog();
            saveFileDialog.AddExtension = true;
            saveFileDialog.CheckFileExists = false;
            saveFileDialog.CheckPathExists = true;
            saveFileDialog.DefaultExt = ".dlsc";
            saveFileDialog.FileName = Path.GetFileName(licenseLocation);
            saveFileDialog.Filter = "License Files *.dlsc|*.dlsc";
            saveFileDialog.FilterIndex = 0;
            saveFileDialog.InitialDirectory = "";
            saveFileDialog.OverwritePrompt = true;
            saveFileDialog.RestoreDirectory = true;
            saveFileDialog.SupportMultiDottedExtensions = false;
            saveFileDialog.Title = _languageFile.GetLangString(45);
            saveFileDialog.ValidateNames = true;
            if (saveFileDialog.ShowDialog() != DialogResult.OK || licenseLocation.Equals(saveFileDialog.FileName, StringComparison.CurrentCultureIgnoreCase))
            {
                return;
            }
            try
            {
                File.Copy(licenseLocation, saveFileDialog.FileName, overwrite: true);
                try
                {
                    File.SetAttributes(saveFileDialog.FileName, FileAttributes.Normal);
                }
                catch
                {
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, _languageFile.GetLangString(46), MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
        }

        public void CopyLicenseFile()
        {
            string text = LicensePath.PathToCertificate();
            if (!File.Exists(text))
            {
                string directoryName = Path.GetDirectoryName(text);
                text = Path.Combine(directoryName, "ManualFormulation.dlsc");
            }
            if (!File.Exists(text))
            {
                return;
            }
            SaveFileDialog saveFileDialog = new SaveFileDialog();
            saveFileDialog.AddExtension = true;
            saveFileDialog.CheckFileExists = false;
            saveFileDialog.CheckPathExists = true;
            saveFileDialog.DefaultExt = ".dlsc";
            saveFileDialog.FileName = Path.GetFileName(text);
            saveFileDialog.Filter = "License Files *.dlsc|*.dlsc";
            saveFileDialog.FilterIndex = 0;
            saveFileDialog.InitialDirectory = "";
            saveFileDialog.OverwritePrompt = true;
            saveFileDialog.RestoreDirectory = true;
            saveFileDialog.SupportMultiDottedExtensions = false;
            saveFileDialog.Title = _languageFile.GetLangString(45);
            saveFileDialog.ValidateNames = true;
            if (saveFileDialog.ShowDialog() != DialogResult.OK || text.Equals(saveFileDialog.FileName, StringComparison.CurrentCultureIgnoreCase))
            {
                return;
            }
            try
            {
                File.Copy(text, saveFileDialog.FileName, overwrite: true);
                try
                {
                    File.SetAttributes(saveFileDialog.FileName, FileAttributes.Normal);
                }
                catch
                {
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, _languageFile.GetLangString(46), MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
        }

        public string SendLicenseFile(string fileName)
        {
            string path = LicensePath.PathToCertificate();
            if (fileName.Length > 0)
            {
                path = fileName;
            }
            if (!File.Exists(path))
            {
                return string.Empty;
            }
            byte[] array;
            using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                array = new byte[fileStream.Length];
                int num = fileStream.Read(array, 0, array.Length);
                fileStream.Close();
                fileStream.Dispose();
            }
            if (array.Length < 1)
            {
                return string.Empty;
            }
            byte[] buffer;
            using (MemoryStream memoryStream = new MemoryStream())
            {
                using (GZipStream gZipStream = new GZipStream(memoryStream, CompressionMode.Compress))
                {
                    gZipStream.Write(array, 0, array.Length);
                    gZipStream.Close();
                    gZipStream.Dispose();
                }
                buffer = memoryStream.GetBuffer();
                memoryStream.Close();
                memoryStream.Dispose();
            }
            if (buffer.Length < 1)
            {
                return string.Empty;
            }
            Encryption encryption = new Encryption();
            return encryption.EncodeByteArray(buffer, 0);
        }

        public void ReplaceLicenseFile(string encryptedFile, string fileName)
        {
            if (string.IsNullOrEmpty(encryptedFile))
            {
                return;
            }
            string path = LicensePath.PathToCertificate();
            if (fileName.Length > 0)
            {
                path = fileName;
            }
            Encryption encryption = new Encryption();
            byte[] buffer = encryption.DecodeStringToByteArray(encryptedFile, 0);
            FileStream fileStream = new FileStream(path, FileMode.Create);
            using (MemoryStream memoryStream = new MemoryStream(buffer))
            {
                using (GZipStream gZipStream = new GZipStream(memoryStream, CompressionMode.Decompress))
                {
                    while (true)
                    {
                        bool flag = true;
                        byte[] buffer2 = new byte[10000];
                        int num = gZipStream.Read(buffer2, 0, 10000);
                        if (num <= 0)
                        {
                            break;
                        }
                        fileStream.Write(buffer2, 0, num);
                    }
                    gZipStream.Close();
                    gZipStream.Dispose();
                }
                memoryStream.Close();
                memoryStream.Dispose();
            }
            fileStream.Close();
            fileStream.Dispose();
        }

        public bool ActivateLicense(string activationCode, ref bool codeReUseWarning)
        {
            codeReUseWarning = false;
            bool result = false;
            _errorMessage = string.Empty;
            string licenseLocation = LicensePath.PathToCertificate();
            DesawareInterface desawareInterface = new DesawareInterface(_desawareServerTimeout);
            ClientLicense desawareClientLicense = desawareInterface.GetDesawareClientLicense();
            try
            {
                if (desawareInterface.InstallClientLicense(activationCode, licenseLocation, out var errorMessage, AllowDeferred: false, suppressMessages: false, ref codeReUseWarning) == InstallClientLicenseResults.LicenseIsGood)
                {
                    result = true;
                }
                else
                {
                    _errorMessage = errorMessage;
                }
            }
            catch (Exception ex)
            {
                _errorMessage = ex.Message;
                if (ex.InnerException != null && !string.IsNullOrEmpty(ex.InnerException.Message))
                {
                    _errorMessage = _errorMessage + Environment.NewLine + ex.InnerException.Message;
                }
            }
            return result;
        }

        public string CreateDeferredCertificate(string activationCode)
        {
            string result = string.Empty;
            _errorMessage = string.Empty;
            string text = LicensePath.PathToCertificate();
            DesawareInterface desawareInterface = new DesawareInterface(_desawareServerTimeout);
            ClientLicense desawareClientLicense = desawareInterface.GetDesawareClientLicense();
            string directoryName = Path.GetDirectoryName(text);
            string text2 = Path.Combine(directoryName, "ManualFormulation.dlsc");
            InstallClientLicenseResults installClientLicenseResults = InstallClientLicenseResults.LicenseWasNotCreated;
            try
            {
                bool codeReUseWarning = false;
                installClientLicenseResults = desawareInterface.InstallClientLicense(activationCode, text2, out var _, AllowDeferred: true, suppressMessages: true, ref codeReUseWarning);
            }
            catch (Exception ex)
            {
                _errorMessage = ex.Message;
                if (ex.InnerException != null && !string.IsNullOrEmpty(ex.InnerException.Message))
                {
                    _errorMessage = _errorMessage + Environment.NewLine + ex.InnerException.Message;
                }
            }
            switch (installClientLicenseResults)
            {
                case InstallClientLicenseResults.LicenseIsGood:
                    try
                    {
                        DeleteFile(text);
                        File.Move(text2, text);
                    }
                    catch (Exception ex)
                    {
                        _errorMessage = ex.Message;
                        if (ex.InnerException != null && !string.IsNullOrEmpty(ex.InnerException.Message))
                        {
                            _errorMessage = _errorMessage + Environment.NewLine + ex.InnerException.Message;
                        }
                        _errorMessage += _languageFile.GetLangString(20);
                    }
                    break;
                case InstallClientLicenseResults.DeferredLicenseHasBeenCreated:
                    result = SendLicenseFile(text2);
                    break;
            }
            return result;
        }
    }
}
